package main

func main() {

}

type Node struct {
	data int
	next *Node
}

type LinkList struct {
	head *Node
}

// AppendNode 向列表增加一个元素
func (l *LinkList) AppendNode(data int) {
	node := &Node{
		data,
		nil,
	}
	if l.head == nil {
		l.head = node
	} else {
		current := l.head
		for current.next != nil {
			current = current.next
		}
		current.next = node
	}

}

func (l *LinkList) DeleteNode(data int) {
	if l.head == nil {
		return
	}
	if l.head.data == data {
		l.head = l.head.next
		return
	}
	current := l.head
	for current.next != nil && current.data != data {
		current = l.head.next
	}
	if current.next != nil {
		current.next = current.next.next
	}
}
